const ologin = document.querySelector(".login")
const owelcome = document.querySelector(".welcome")
const oun = document.querySelector(".un")
const oexit = document.querySelector(".exit")
const ogoCart = document.querySelector(".goCart")
const obtns = document.querySelector(".btns")
// 读取登录信息
if(localStorage.getItem("isLogin") === "ok"){
    ologin.style.display = "none";
    obtns.style.display = "none"
    owelcome.style.display = "block";
    oun.innerHTML = localStorage.getItem("username");
}else{
    ologin.style.display = "block";
    owelcome.style.display = "none";
    obtns.style.display = "block"
    oun.innerHTML = "";
}

oexit.onclick = function(){
    localStorage.removeItem("username");
    localStorage.setItem("isLogin", "");
    ologin.style.display = "block";
    owelcome.style.display = "none";
    obtns.style.display = "block"
    oun.innerHTML = "";
}

ogoCart.onclick = function(){
    if(localStorage.getItem("isLogin") === "ok"){
        location.href = "../cart.html"
    }else{
        alert("未登录状态，不允许打开购物车，请先登录")
        location.href = "../login.html"
    }
}

